<template>
	<div>
		<a-form style="width: 100%" layout="vertical">
			<!--联动/下钻-->
			<receive-publish-config :publishParams="publishParams"></receive-publish-config>
			<drill-down-config v-if="!table" :screenConfig="screenConfig"></drill-down-config>
		</a-form>
	</div>
</template>

<script>
import ReceivePublishConfig from "./receive-publish-config.vue";
import DrillDownConfig from "./drill-down-config.vue";
export default {
	name: "ChartAdvConfig",
	components:{
		ReceivePublishConfig,
		DrillDownConfig
	},
	props:["screenConfig","table","params"],
	inject:{
		config:{
			default:()=>{
				return {};
			}
		}
	},
	data() {
		return {
			//发布参数
			publishParams: [],
		}
	},
	created() {
		this.initPublishParams();
	},
	methods: {
		initPublishParams() {
			this.publishParams=[];
            if(this.params && this.params.length>0){
                this.publishParams=this.params;
                return;
            }
			//维度
            if( this.config.dataSources.dimensions){
                for (let i = 0; i < this.config.dataSources.dimensions.length; i++) {
                    let obj=this.config.dataSources.dimensions[i];
                    this.publishParams.push({
                        label:obj.fieldLabel,
                        value: obj.tableName + "." + obj.fieldName
                    });
                }
            }
			//度量
            if(this.config.dataSources.measures){
                for (let i = 0; i < this.config.dataSources.measures.length; i++) {
                    let obj=this.config.dataSources.measures[i];
                    this.publishParams.push({
                        label:obj.fieldLabel,
                        value: obj.tableName + "." + obj.fieldName
                    });
                }
            }
			//颜色图例
			if(this.config.dataSources.colorLegends){
				for (let i = 0; i < this.config.dataSources.colorLegends.length; i++) {
					let obj=this.config.dataSources.colorLegends[i];
					this.publishParams.push({
						label:obj.fieldLabel,
						value: obj.tableName + "." + obj.fieldName
					});
				}
			}
		}
	}
}
</script>

<style scoped>
</style>
